<template>
  <div class="inform">
    <header>
      <p>
        <router-link to="/">《</router-link>
      </p>
      <p>资讯</p>
      <p>
        <span>...</span>
        <span>o</span>
      </p>
    </header>
    <main>
      <div class="hotroom">
        <div
          class="hotroomlist"
          v-for="(item,index) in hotRoom"
          :key="index"
          @click="houseDetail(item.id)"
        >
          <dl>
            <dt>
              <img :src="item.img" alt />
            </dt>
            <dd>
              <p>{{item.tit}}</p>
              <p>{{item.word}}</p>
              <p>
                <span>{{item.sum}}万</span>
                <span>{{item.price}}元 / m</span>
              </p>
              <p>
                <button>{{item.type}}</button>
                <button>{{item.orientation}}</button>
              </p>
            </dd>
          </dl>
        </div>
      </div>
    </main>
  </div>
</template>

<script>
import { hotRoom } from "../../../../api/index";
import axios from "axios";

export default {
  name: "index",
  data() {
    return {
      hotRoom: []
    };
  },
  created() {
    this.hotroom();
  },
  methods: {
    hotroom() {
      hotRoom().then(res => {
        if (res.data.code === 0) {
          this.$router.push("/login");
          this.$toast(res.data.msg);
        } else {
          this.hotRoom = res.data.data;
        }
      });
    },
    //进入详情页
    houseDetail(id) {
      this.$router.push(`/Detail/${id}`);
    }
  }
};
</script>

<style lang="scss" scoped>
.inform {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  header {
    display: flex;
    align-items: center;
    justify-content: space-around;
    height: 60px;
    background-color: rgb(34, 100, 177);
    color: #fff;

    p:first-child {
      a {
        color: #fff;
      }
    }
    p:nth-child(3) {
      border: 1px solid rgb(226, 226, 226);
      width: 60px;
      height: 26px;
      border-radius: 26px;
      display: flex;
      align-items: center;
      justify-content: space-around;
    }
  }
  main {
    border-top: 2px solid rgb(182, 238, 149);
    flex: 1;
    overflow-y: scroll;
    .hotroom {
      width: 100%;
      height: auto;
      p {
        width: 100%;
        height: 40px;
        display: flex;
        justify-content: space-between;
        align-items: center;
        span:first-child {
          font-size: 20px;
          font-weight: bold;
          // margin-left: 20px;
        }
        span:nth-child(2) {
          font-size: 18px;
          margin-right: 20px;
          color: rgb(151, 149, 149);
        }
      }
      .hotroomlist {
        dl {
          width: 100%;
          height: 120px;
          display: flex;
          align-items: center;
          border-bottom: 1px solid rgb(221, 221, 221);
          dt {
            img {
              width: 120px;
              height: 100px;
            }
          }
          dd {
            p {
              height: 23px;
            }
            p:first-child {
              font-size: 14px;
              font-weight: 600;
            }
            p:nth-child(2) {
              font-size: 14px;
            }
            p:nth-child(3) {
              font-size: 14px;
              display: flex;
              justify-content: start;
              span:first-child {
                font-size: 14px;
                color: rgb(255, 196, 0);
              }
              span:nth-child(2) {
                font-size: 14px;
                margin-left: 10px;
              }
            }
          }
        }
      }
    }
  }
}
</style>